package com.jhondge.skia.view;

import com.jhondge.skia.SkiaDemoActivity;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

public class SkiaView extends View {

	
	private final String TAG = SkiaView.class.getSimpleName();
	
	public SkiaView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public SkiaView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public SkiaView(Context context) {
		super(context);
		init(SkiaDemoActivity.SDCARD_SKIA_DEMO + "splash.jpg");
	}

	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		Log.d(TAG, "onDraw");
		renderSkia(canvas);
	}
	
	public void finish(){
		Log.d(TAG, "finish");
		release();
	}

	public native void renderSkia(Canvas canvas);
	
	public native void init(String path);
	
	public native void release();
	
	public native Bitmap loadBitmap(String filePath);
	
	static{
		System.loadLibrary("skia_demo");
	}
}
